package basics;


import tween.Ticker;
import framework.types.TSize.FloatSize;

import tween.Tween;
import basics.StartState;

import pixi.core.utils.Utils;
import pixi.plugins.app.Application;
import pixi.core.graphics.Graphics;
import pixi.core.textures.Texture;
import pixi.core.sprites.Sprite;


class Main extends Application {

	var _background:Sprite;
	var _graphic:Graphics;

	public var value:Int = 100;

	public function new() {
		super();

		position = Application.POSITION_FIXED;
		backgroundColor = 0x006666;
		transparent = true;
		antialias = true;
		onUpdate = this._onUpdate;
		super.start();



//		stage.scale.set( pixelRatio);

		_background = new Sprite(Texture.fromImage("assets/textures/bkg/game.jpg"));
		_background.anchor.set(0.5);
		_background.position.set(width * 0.5, height * 0.5);
		stage.addChild(_background);


		var designSize = new FloatSize(720, 1280);
		var rw = width / designSize.width ;
		var rh = height / designSize.height;
		var r = Math.max(rw, rh);
		_background.scale.set(r);

		SceneManager.instance.root = _background;
		SceneManager.instance.runState(new StartState());

	}

	function _onUpdate(e:Float) {
		Tween.tick(this.app.ticker.elapsedMS, false);
		SceneManager.instance.onUpdate(this.app.ticker.elapsedMS);
	}

	static function main() {
		new Main();
	}
}